import React from "react"

import http from "../../helper/request"

const useApi = () => {
	const { useState } = React
	const [loading, setLoading] = useState(false)

	async function generalHttp<T>(url: string, body: object | undefined) {
		setLoading(true)
		const ret = await http.post<T>(url, body)
		setLoading(false)
		return ret
	}
	// 周期列表
	const proxyTeamBillPeriod = async (body: object | undefined) => {
		const ret = await generalHttp("/report/proxyTeamBill/period/list", body)
		return ret
	}
	const proxyTeamBillList = async (body: object | undefined) => {
		const ret = await generalHttp("/report/proxyTeamBill/listPage", body)
		return ret
	}

	const proxyTeamBillListSummary = async (body: object | undefined) => {
		const ret = await generalHttp("/report/proxyTeamBill/summary", body)
		return ret
	}
	const proxyTeamBillListDetail = async (body: object | undefined) => {
		const ret = await generalHttp("/report/proxyTeamBill/detail", body)
		return ret
	}
	return {
		proxyTeamBillListDetail,
		proxyTeamBillListSummary,
		proxyTeamBillList,
		proxyTeamBillPeriod,
		generalHttp,
		loading
	}
}

export default useApi
